<!DOCTYPE html>
<html lang="ar">
<head>
    <title>الحساب الاداري</title>
	<?php
	 define('LAST_CAPITRE_ID',19);
	 define('LAST_ARTICLE_CODE',3);
	?>

	<?php $this->load->helper('url');?>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta charset="utf-8">

<!---------------------for autocomplete--------------->
	<script type="text/javascript" src="<?php echo base_url('assets/js/jquery-1.11.0.min.js');?>" ></script>
	<script type="text/javascript" src="<?php echo base_url('assets/js/jquery-ui-1.10.4/js/jquery-ui-1.10.4.min.js');?>" ></script>
	<link href="<?php echo base_url("assets/css/jquery-ui.css")?>" rel="stylesheet" type="text/css" />
	<!------------------------------------------------------>
<!---------------------for form css ----------------------->
	<link href="<?php echo base_url("assets/css/pure.css")?>" rel="stylesheet" type="text/css" />
	
<script type="text/javascript" src="<?php echo base_url('assets/js/jquery.tablesorter.min.js');?>" ></script>
 <link href="<?php echo base_url("assets/css/botton.css")?>" rel="stylesheet" type="text/css" />
	
</head>


<?php include_once('header.php');

		//$r=$les_convention;
		 $this->load->library('session');
        $num_ar=$this->session->userdata('data_charticle'); //access it
        $chcl=$num_ar;
 ?>
 


<?PHP
 $year=$this->session->userdata('annee');
$montant_consomer=0;
for($i=11;$i<20;$i++){
	$montant_consomer=$montant_consomer+$chapitres[$i];
}


if(array_key_exists('0', $result) ){
	$budget_initial=$result[0]->montant_globale;
}else{
	$budget_initial=0;
	$result[0]->ch_11=0;$result[0]->ch_12=0;$result[0]->ch_13=0;$result[0]->ch_14=0;$result[0]->ch_15=0;
	$result[0]->ch_16=0;$result[0]->ch_17=0;$result[0]->ch_18=0;$result[0]->ch_19=0;
}

if(array_key_exists('1', $result) ){
	$budget_suplementaire=$result[1]->montant_globale;
}else{
	$budget_suplementaire=0;
	$result[1]->ch_11=0;$result[1]->ch_12=0;$result[1]->ch_13=0;$result[1]->ch_14=0;$result[1]->ch_15=0;
	$result[1]->ch_16=0;$result[1]->ch_17=0;$result[1]->ch_18=0;$result[1]->ch_19=0;
}

/*if(array_key_exists('1', $result)){
	$budget_suplementaire=$result[1]->montant_globale;
}else{
	$budget_suplementaire=0;
}*/
$le_rest=$budget_initial+$budget_suplementaire-$montant_consomer;

?>

<form id="convention_form" class="pure-form pure-form-stacked"  method="POST" action="<?php echo base_url('/etat_financier_ctr/');?>">
    
        <legend>الحساب الاداري لسنة : <?php echo('<strong>'.$year.'</strong>');?></legend>

        <div class="pure-g">
		 <div class="pure-u-1 pure-u-md-1-3" style="width: 90%">
		  
		 </div>
            <div class="pure-u-1 pure-u-md-1-3" style="width: 30%">
                <label for="fournisseur">الاعتمادات المفوضة </label>
				<label  style="display: inline-block" class="ltr"><?php echo(number_format($budget_initial, 2, ',', ' '));?></label>
            </div>
			 <div class="pure-u-1 pure-u-md-1-3" style="width: 30%">
                <label for="fournisseur">الاعتمادات المعدلة </label>
				<label  style="display: inline-block" class="ltr"><?php echo(number_format($budget_suplementaire, 2, ',', ' '));?></label>
            </div>
			<div class="pure-u-1 pure-u-md-1-3" style="width: 30%">
                <label for="fournisseur">الاعتمادات المراجعة </label>
				<label  style="display: inline-block" class="ltr"><?php echo(number_format($budget_initial+$budget_suplementaire, 2, ',', ' '));?></label>
            </div>
			
			 <div class="pure-u-1 pure-u-md-1-3" style="width: 30%">
                <label for="fournisseur">الالتزامات </label>
				<label  style="display: inline-block" class="ltr"><?php echo(number_format($montant_consomer, 2, ',', ' '));?></label>
            </div>
			
			
			
			
			
			 <div class="pure-u-1 pure-u-md-1-3" style="width: 30%">
                <label for="fournisseur">رصيد الالتزامات</label>
				<label  style="display: inline-block" class="ltr"><?php echo(number_format($le_rest, 2, ',', ' '));?></label>
            </div>
			
<?php	
$compt=0;//compteur pour la table des noms de chapitres
for($k=11;$k<20;$k++){
	$num_ch='ch_'.$k;	
	$rest=$result[0]->$num_ch +$result[1]->$num_ch - $chapitres[$k];	

	$d=0;
		echo('		   <div class="pure-u-1 pure-u-md-1-3" style="width: 90%">
		    <label style="font-size: 130%; text-decoration: underline; color: red;"><a href="'.base_url("/calcule_administrative_ctr/detaille_chapitre/$k").'"> '.$nom_chapitres[$compt]->nom.'</a></label>
			 </div>
         <div class="pure-u-1 pure-u-md-1-3 " style="width: 30%">
                <label for="article">الاعتمادات المفوضة </label>
				<label  style="display: inline-block" class="ltr">'.number_format($result[0]->$num_ch, 2, ',', ' ').'</label>
            </div>
			
			<div class="pure-u-1 pure-u-md-1-3 " style="width: 30%">
                <label for="article">الاعتمادات المعدلة </label>
				<label  style="display: inline-block" class="ltr">'.number_format($result[1]->$num_ch, 2, ',', ' ').'</label>
            </div>
			
			<div class="pure-u-1 pure-u-md-1-3 " style="width: 30%">
                <label for="article">الاعتمادات المراجعة </label>
				<label  style="display: inline-block" class="ltr">'.number_format($result[0]->$num_ch+$result[1]->$num_ch, 2, ',', ' ').'</label>
            </div>
			
			 <div class="pure-u-1 pure-u-md-1-3" style="width: 30%">
                <label for="fournisseur">الالتزامات </label>
					<label  style="display: inline-block" class="ltr">'.number_format($chapitres[$k], 2, ',', ' ').'</label>
            </div>
			 <div class="pure-u-1 pure-u-md-1-3" style="width: 30%">
                <label for="fournisseur">رصيد الالتزامات </label>
					<label  style="display: inline-block" class="ltr">'.number_format($rest, 2, ',', ' ').'</label>
            </div>
			
			
			');
			$compt++;
			}
?>			
		
		 
			
			 </div>
			     <?php

	echo ('
	 <a href="'.base_url('/budget_ctr/load/').'" class="pure-button pure-button-primary" >خروج</a>');

?>
	
		</form>


  <script>
 $(document).ready(function() 
    { 
        $("#myTable").tablesorter(); 
    } 
); 
 </script>  
  <script>
$(function() {
	var liste_fourniss = <?php echo json_encode($liste_des_fournisseurs); ?>;
	$( "#nom" ).autocomplete({source: liste_fourniss});
	} 
); 
</script> 

</html>